function isPalindrome(x: number): boolean {
  if (x === 0) return true
  if (x < 0 || x % 10 === 0) return false
  let reversed = 0
  let mid = x
  while(mid > 0) {
    reversed = reversed * 10 + mid % 10
    mid = Math.floor(mid / 10)
  }
  return reversed === x
}